﻿//ACV_Garbage.sqf
#include "ACV_constantes.h"
[] spawn {
	private ["_tmp","_params"];
	_tmp = ACV_GARBAGE_TEMPO/2;
	while {true} do {
		sleep _tmp;
		{	if ([_x, ACV_GARBAGE_CLOSER_DISTANCE] call R3F_FNCT_IsObject_Visible) then {
				_action_params = 0;
				if (!isnil "XfMissionGetParameters") then {	_action_params = count (_x call XfMissionGetParameters);};
				if (_action_params <= 0) then { deletevehicle _x; };
			};			
			sleep 0.01;
		} foreach alldead;
		sleep _tmp;
		{	if ((count units _x) == 0) then {		
				_params = [];
				_params set [ACV_NET_PARAM_CLASS, _x];
				_params set [ACV_NET_PARAM_OWNER, "Server Garbage"];
				_params set [ACV_NET_PARAM_DISPLAYNAME, "Group"];
				[_params] call ACV_FNCT_DeleteUnit;
				deletegroup _x;
			};
			sleep 0.01;
		} foreach allgroups;
	};
};